package com.qf.boot.service.consumer;

import com.qf.boot.service.api.SiteService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

@EnableAutoConfiguration
public class StubDubboConsumer {


    /*
    消费者 stub = "true"
    在my-boot-dubbo-interfaces接口模块中，创建SiteServiceStub实现SiteService接口，本地存根
     */
    @Reference(version = "timeout",timeout = 2000,stub = "true")
    private SiteService siteService;

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(StubDubboConsumer.class);
        SiteService siteService = (SiteService) context.getBean(SiteService.class);
        String name =  siteService.getName("q-stub");
        System.out.println(name);
    }
}
